<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<link rel="stylesheet"  href="/layui/css/layui.css"/>
<meta charset="UTF-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>用户列表</title>
</head>
<body>
<script src="/plugins/jquery/jquery-1.10.2.min.js"></script>
<script  src="/layui/layui.js"></script>
<script src="/plugins/js/common.js"></script>
<form class="layui-form" action="/user/addUser" id="saveForm">
	<br>
	<div class="layui-form-item">
	    <div class="layui-inline">
	      <input type="hidden" id="pId"  th:value="${areaInfo.pId}">	
	      <input type="hidden" name="id"  th:value="${areaInfo.id}">	
	      <label class="layui-form-label">父区域：</label>
	      <div class="layui-input-inline">
	        <input  th:value="${parentAreaInfo.name}" autocomplete="off" style="width: 260px;" readonly="readonly" class="layui-input">
	      </div>
	    </div>
  </div>
  <div class="layui-form-item">
	    <div class="layui-inline">
	      <label class="layui-form-label">区域名称：</label>
	      <div class="layui-input-inline">
	        <input type="tel" name="name" th:value="${areaInfo.name}" placeholder="请输入区域名称" lay-verify="required" style="width: 260px;" autocomplete="off" class="layui-input">
	      </div>
	    </div>
  </div>
   <div class="layui-form-item">
	    <div class="layui-inline">
	      <label class="layui-form-label">所属级别：</label>
	      <div class="layui-input-inline">
	        <div th:switch="${areaInfo.grade}" class="layui-form-mid layui-word-aux">
				<p th:case="2">市</p>
				<p th:case="3">区县</p>
			</div>
	      </div>
	    </div>
  </div>
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit="" lay-filter="saveArea">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>
<script type="text/javascript">
layui.use(['form', 'layedit', 'laydate'], function(){
	 form = layui.form;
	 form.on('submit(saveArea)', function(data){
		  $.post("",JSON.stringify(data.field));
		  $.ajax({
              url: "/area/updateAreaInfo",
              data: data.field,
              type: "post",
              success: function (result) {
            	if(result){
            		parent.refresh($("#pId").val());
            		layMsg("修改成功",2000);
                	var index = parent.layer.getFrameIndex(window.name);
                	setTimeout(function(){parent.layer.close(index)}, 1000);
            	}else{
            		layMsg("修改失败",2000);
            	}
              },
              error: function (result) {
            	  layMsg("请求异常",2000);
              }
		});
	return false;	  
	});
});

//监听提交

// function addUser(){
// // 	alert("提交");
// 	$("#saveForm").submit();
	
// }

</script>
</body>
</html>